`
https://leetcode.cn/problems/letter-case-permutation/
`

/**
 * @param {string} s
 * @return {string[]}
 */
var letterCasePermutation = function (s) {
  const res = []
  const track = []

  function traverse(index) {
    if (index === s.length) {
      res.push(track.join(''))
      return
    }

    // 是数字就继续遍历，是字母就分大小写遍历
    if (s.charCodeAt(index) >= '0'.charCodeAt(0) && s.charCodeAt(index) <= '9'.charCodeAt(0)) {
      track.push(s[index])
      traverse(index + 1)
      track.pop()
    } else {
      track.push(s[index].toLowerCase())
      traverse(index + 1)
      track.pop()

      track.push(s[index].toUpperCase())
      traverse(index + 1)
      track.pop()
    }
  }

  traverse(0)
  return res
};